package cn.itcast.service.impl;

import cn.itcast.mapper.LogMapper;
import cn.itcast.pojo.OperateLog;
import cn.itcast.pojo.PageInfo;
import cn.itcast.pojo.QueryString;
import cn.itcast.pojo.QuerysString;
import cn.itcast.service.LogService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Component
public class LogServiceImpl implements LogService {
    @Autowired
    private LogMapper logMapper;
    @Override
    public PageInfo<OperateLog> page(QuerysString querysString) {
        PageHelper.startPage(querysString.getPage(), querysString.getPageSize());
        List<OperateLog> logs = logMapper.page();

        Page<OperateLog> logs1 = (Page<OperateLog>) logs;

        return new PageInfo<>((int) logs1.getTotal(),logs1.getResult());
    }
}
